//轮播图
var carouselMap = {}
carouselMap.MapInit = function (map, obj) {
    obj.index = 0;
    obj.w = map.width();
    obj.its = map.find(".items");
    obj.it = map.find(".item");
    map.css({ "position": "relative" });
    obj.its.css({ "width": 2 * obj.w, "height": "100%", "position": "absolute" });
    obj.it.css({ "width": obj.w, "height": "100%", "position": "absolute", "left": 2 * obj.w });
    obj.it.eq(0).css({ "left": "0px" });
}
carouselMap.Jump = function (obj, index) {
    index > obj.it.length - 1 ? index = 0 : index
    index < 0 ? index = obj.it.length - 1 : index
    if (index == obj.index) {
        return index
    } else {
        obj.it.css({ "left": 2 * obj.w });
        if (index > obj.index || index == obj.it.length - 1) {
            obj.its.css({ "left": "0px" });
            obj.it.eq(obj.index).css({ "left": "0px" });
            obj.index = index;
            obj.it.eq(obj.index).css({ "left": obj.w + "px" });
            obj.its.animate({ "left": -(obj.w) + "px" }, 500)
        } else if (index < obj.index || index == 0) {
            obj.its.css({ "left": -(obj.w) + "px" });
            obj.it.eq(obj.index).css({ "left": obj.w + "px" })
            obj.index = index;
            obj.it.eq(obj.index).css({ "left": "0px" });
            obj.its.animate({ "left": "0px" }, 500)
        }
        return obj.index
    }
}

carouselMap.banner = {}
carouselMap.MapInit($(".shop-carousel-map"), carouselMap.banner);

$(".shop-controller > div").on("click", function(){
    carouselMap.Jump(carouselMap.banner, $(this).index());
    $(this).addClass("shop-div-s").siblings("div").removeClass("shop-div-s")
})


// 导航栏吸顶

document.onscroll = function(){
    if($(this).scrollTop() > 120){
        $(".shop-nav").addClass("shop-fixed");
    }else{
        $(".shop-nav").removeClass("shop-fixed");
    }
}

$(".shop-search input").on("focus", function(){
    $(".shop-search .shop-index").hide();
}).on("focusout", function(){
    if($(this).val() == ""){
        $(".shop-search .shop-index").show();
    }
});

$(".shop-nav-class-all").hover(function(){
    $(this).find(".class-all").show();
}, function(){
    $(this).find(".class-all").hide();
});




// Message.Show("提示", "恭喜你领取成功",true);

Message.Show("提示", "恭喜你领取成功", "right",true, 5)